package src.thread;
/*
获取一个线程相关信息的方法
 */
public class ThreadInfoDemo {
        public static void main(String[] args) {
                Thread t=new Thread("君jun"){
                        @Override
                        public void run() {
                                super.run();
                                String name=this.getName();
                                System.out.println(name);
                                long id=this.getId();
                                System.out.println(id);
                                int priority = this.getPriority();
                                System.out.println(priority);
                                //线程是否被中断
                                boolean isInterrupted = this.isInterrupted();
                                //线程是否为守护线程
                                boolean isDaemon = this.isDaemon();
                                //线程是否还活着
                                boolean isAlive = this.isAlive();
                                System.out.println("是否被中断:"+isInterrupted);
                                System.out.println("是否是守护线程:"+isDaemon);
                                System.out.println("是否还活着:"+isAlive);
                        }
                };
                t.start();
        }
}
